// createWebHashHistory 是hash模式就是访问链接带有#
// createWebHistory  是history模式
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router"

const routes = [
    {
        path: "/",
        name: "Login",
        meta: {
            title: "登录",
        },
        component: () => import("../views/Login.vue"),
    },
    {
        path: "/Home",
        name: "Home",
        meta: {
            title: "花数云控制台",
        },
        component: () => import("../views/Home.vue"),
    },
    {
        path: "/Tenant/TenantList",
        name: "TenantList",
        meta: {
            title: "租户列表",
        },
        component: () => import("../views/Tenant/TenantList.vue"),
    },
    {
        path: "/Tenant/TenantRecord",
        name: "TenantRecord",
        meta: {
            title: "租户记录",
        },
        component: () => import("../views/Tenant/TenantRecord.vue"),
    },
    {
        path: "/Config/ConfigEdition",
        name: "ConfigEdition",
        meta: {
            title: "版本管理",
        },
        component: () => import("../views/Config/ConfigEdition.vue"),
    },
    {
        path: "/Config/ConfigEditionDetail",
        name: "ConfigEditionDetail",
        meta: {
            title: "版本详情",
            showBread: true,
        },
        component: () => import("../views/Config/ConfigEditionDetail.vue"),
    },
    {
        path: "/Config/ConfigEditionEdit",
        name: "ConfigEditionEdit",
        meta: {
            title: "编辑版本管理",
            showBread: true,
        },
        component: () => import("../views/Config/ConfigEditionEdit.vue"),
    },
    {
        path: "/News/NewsClass",
        name: "NewsClass",
        meta: {
            title: "文章分类",
        },
        component: () => import("../views/News/NewsClass.vue"),
    },
    {
        path: "/News/NewsList",
        name: "NewsList",
        meta: {
            title: "文章列表",
        },
        component: () => import("../views/News/NewsList.vue"),
    },
    {
        path: "/News/NewsAdd",
        name: "NewsAdd",
        meta: {
            title: "文章添加",
            showBread: true,
        },
        component: () => import("../views/News/NewsAdd.vue"),
    },
    {
        path: "/News/NewsEdit",
        name: "NewsEdit",
        meta: {
            title: "文章编辑",
            showBread: true,
        },
        component: () => import("../views/News/NewsEdit.vue"),
    },
    {
        path: "/News/Mail",
        name: "Mail",
        meta: {
            title: "站内信",
        },
        component: () => import("../views/News/Mail.vue"),
    },
    {
        path: "/Notice/NoticeList",
        name: "Notice",
        meta: {
            title: "消息列表",
            showBread: true,
        },
        component: () => import("../views/Notice/NoticeList.vue"),
    },
    {
        path: "/Picture/PictureClassify",
        name: "PictureClassify",
        meta: {
            title: "图片分类",
        },
        component: () => import("../views/Picture/PictureClassify.vue"),
    },
    {
        path: "/Picture/PictureList",
        name: "PictureList",
        meta: {
            title: "图片列表",
        },
        component: () => import("../views/Picture/PictureList.vue"),
    },
    {
        path: "/Notice/NoticeDetail",
        name: "NoticeDetail",
        meta: {
            title: "查看详情",
            showBread: true,
        },
        component: () => import("../views/Notice/NoticeDetail.vue"),
    },
    {
        path: "/Help",
        name: "Help",
        meta: {
            title: "帮助中心",
        },
        component: () => import("../views/Help.vue"),
    },
    {
        path: "/ChangePass",
        name: "ChangePass",
        meta: {
            title: "修改密码",
        },
        component: () => import("../views/ChangePass.vue"),
    },
    {
        path: "/Page403",
        name: "Page403",
        meta: {
            title: "页面403",
        },
        component: () => import("../views/Page403.vue"),
    },
    {
        path: "/:pathMatch(.*)*", // 代替vue2的通配符path: "*",
        name: "Page404",
        meta: {
            title: "页面404",
        },
        component: () => import("../views/Page404.vue"),
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes,
})

// 路由拦截
router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title + '_花数云控制台'
    }
    next()
})

export default router
